/*
 * PlaySongAction.java
 *
 * Created on April 8, 2006, 1:59 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.bff.mpd.musicjukebox.lib.actions;

import com.bff.mpd.utils.Utils;
import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.Action;
import org.bff.javampd.MPDPlayer;
import org.bff.javampd.exception.MPDConnectionException;
import org.bff.javampd.exception.MPDPlayerException;
import org.bff.javampd.objects.MPDSong;

/**
 *
 * @author Bill
 */
public class PlaySongAction extends AbstractAction {
    private MPDPlayer player;
    private MPDSong song;
    
    /** Creates a new instance of PlayAction */
    public PlaySongAction(MPDPlayer player, MPDSong song) {
        super(Utils.getMessage("ACTION_PLAY_SONG_NAME"));
        this.player = player;
        this.song = song;
        putValue(Action.SHORT_DESCRIPTION,  Utils.getMessage("ACTION_PLAY_SONG_SHORT_DESC"));
    }
    
    @Override
    public void actionPerformed(ActionEvent evt) {
        try {
            player.playId(song);
        } catch (MPDConnectionException ex) {
            Logger.getLogger(PlaySongAction.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MPDPlayerException ex) {
            Logger.getLogger(PlaySongAction.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
